@extends("layouts.backend.webadmin")

@section('content')
    <link rel="stylesheet" href="{{env('APP_ROOT')}}/css/goodslist.css">
    <!-- 主体部分 -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <a class="btn btn-primary goods-add" href="{{ URL::route('admin.goods.goodsadd') }}" role="button"><i class="fa fa-plus-square" aria-hidden="true"></i> 增加</a>
                        <a class="btn btn-warning goods-restore" href="{{ URL::route('admin.goods.goodslist',['type'=>1]) }}" role="button"><i class="fa fa-trash-o" aria-hidden="true"></i> 回收站</a>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table id="goodstable" class="table table-bordered table-striped">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>名称</th>
                                <th>商品分类</th>
                                <th>已售数量</th>
                                <th>商品简述</th>
                                <th>缩略图</th>
                                <th>商品价格</th>
                                <th>库存</th>
                                <th>是否上架</th>
                                <th>是否推荐</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach ($lists as $list)
                                <tr>
                                    <td>{{$list->sn}}</td>
                                    <td>{{$list->goods_name}}</td>
                                    <td>{{$list->cate_name}}</td>
                                    <td>{{$list->saled_num}}</td>
                                    <td>{{$list->despt}}</td>
                                    <td><img src="{{URL::asset($list->thumb)}}" width="40" height="40" /></td>
                                    <td>{{$list->price}}</td>
                                    <td>{{$list->stock}}</td>
                                    <td>@if($list->on_sale) 是 @else 否 @endif</td>
                                    <td>@if($list->is_recommented) 是 @else 否 @endif</td>
                                    <td>{{$list->created_at}}</td>
                                    <td>
                                        @if($type==0)
                                            <a class="btn btn-primary goods-update" href="{{ URL::route('admin.goods.goodsupdate',['id'=>$list->gid]) }}" role="button"><i class="fa fa-pencil fa-fw"></i>编辑</a>
                                            <a class="btn btn-danger goods-delete" data-href="{{ URL::route('admin.goods.goodsdel',['id'=>$list->gid]) }}" role="button"><i class="fa fa-trash-o fa-fw"></i>删除</a>
                                        @else
                                            <a class="btn btn-primary goods-restore" href="{{ URL::route('admin.goods.goodsrestore',['id'=>$list->gid]) }}" role="button"><i class="fa fa-pencil fa-fw"></i>恢复</a>
                                            <a class="btn btn-danger goods-forcedel" href="{{ URL::route('admin.goods.goodsforcedel',['id'=>$list->gid]) }}" role="button"><i class="fa fa-trash-o fa-fw"></i>彻底删除</a>
                                        @endif
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
{{--                        {{$lists->links()}}--}}
                    </div>
                    <!-- /.box-body -->
                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </section>
    <!-- 主体部分结束 -->
@stop

@section('javascript-end')
    <script src="{{env('APP_ROOT')}}/assets/layui/layui.all.js"></script>
    <script src="{{env('APP_ROOT')}}/js/layertips.js"></script>
    <script>
        $('#goodstable').DataTable({
            'paging'      : false,
            'lengthChange': false,
            'searching'   : false,
            'ordering'    : false,
            'info'        : false,
            'autoWidth'   : true,
            'pagingType'  : "simple_numbers",  //分页样式：simple,simple_numbers,full,full_numbers
            'oLanguage'   :{
                'sUrl'    : '{{env("APP_ROOT")}}/assets/bootstrap/js/zh_cn.json'
            }
        });
        $(function(){
            $('img').each(function(){
                $(this).click(function(){
                    var img = $(this).attr('src');
                    var content = "<img src='"+img+"' style='border:10px #fff solid'/>";
                    layer.open({
                        type: 1,
                        title: false,
                        closeBtn: 0,
                        anim: 2,
                        area: ['auto','auto'],
                        skin: 'layui-layer-nobg', //没有背景色
                        shadeClose: true,
                        content: content
                    });
                });

            });
        });
    </script>
@endsection